<template>
	<div ref="AppUser">
		<el-dialog title="APP用户" :visible.sync="dialogFormVisible" :close-on-press-escape="false"
			:close-on-click-modal="false" @closed="afterCloseDialog">
			<el-form :model="appUserForm" ref="appUserForm" label-width="100px">
				<el-row>
					<el-col :md="24">
						<el-form-item label="头像" prop="userPhoto">
							<el-avatar v-if="appUserForm.userPhoto" :src="$util.showFile(appUserForm.userPhoto)"
								fit="contain" shape="square" :size="100"></el-avatar>
							<el-avatar v-else :src="require('@/assets/images/default_user.jpg')" fit="contain"
								shape="square" :size="100">
							</el-avatar>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :md="12">
						<el-form-item label="用户名" prop="uname">
							{{appUserForm.uname}}
						</el-form-item>
					</el-col>
					<el-col :md="12">
						<el-form-item label="状态" prop="status">
							<span v-if="appUserForm.status == '0'">正常</span>
							<span v-if="appUserForm.status == '1'">注销</span>
							<span v-if="appUserForm.status == '2'">禁用</span>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :md="12">
						<el-form-item label="手机号" prop="phone">
							{{appUserForm.phone}}
						</el-form-item>
					</el-col>
					<el-col :md="12">
						<el-form-item label="昵称" prop="nickname">
							{{appUserForm.nickname}}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :md="12">
						<el-form-item label="性别" prop="sex">
							<span v-if="appUserForm.sex == '0'">女</span>
							<span v-else-if="appUserForm.sex == '1'">男</span>
							<span v-else-if="appUserForm.sex == '2'">未知</span>
							<span v-else>--</span>
						</el-form-item>
					</el-col>
					<el-col :md="12">
						<el-form-item label="出生日期" prop="birthday">
							{{appUserForm.birthday ? $util.dateFormat(appUserForm.birthday, 'yyyy-MM-dd') : '--'}}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :md="12">
						<el-form-item label="注册方式" prop="registerType">
							<span v-if="appUserForm.registerType == '1'">微信小程序授权</span>
							<span v-if="appUserForm.registerType == '2'">手机号注册</span>
							<span v-if="appUserForm.registerType == '3'">APP微信授权</span>
						</el-form-item>
					</el-col>
					<el-col :md="12">
						<el-form-item label="注册时间" prop="registerTime">
							{{appUserForm.registerTime}}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :md="24">
						<el-form-item label="个性签名" prop="signature">
							{{appUserForm.signature ? appUserForm.signature : '--'}}
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogFormVisible = false">返回</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		name: "AppUser",
		data() {
			return {
				dialogFormVisible: false,
				appUserForm: {
					uname: null,
					pwd: null,
					phone: null,
					nickname: null,
					userPhoto: null,
					sex: null,
					birthday: null,
					signature: null,
					status: null,
					registerType: null,
					registerTime: null
				}
			};
		},
		methods: {
			initForm(id) {
				if (id) {
					this.appUserForm.id = id;
					this.$api.post('/appUser/getById', {
						id: id
					}).then(response => {
						this.dialogFormVisible = true;
						let appUser = response.data;
						this.appUserForm = appUser;
					});
				}
			},
			afterCloseDialog() {
				this.appUserForm = {
					uname: null,
					pwd: null,
					phone: null,
					nickname: null,
					userPhoto: null,
					sex: null,
					birthday: null,
					signature: null,
					status: null,
					registerType: null,
					registerTime: null
				};
			}
		}
	};
</script>
